<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	
	
	<xsl:include href="../../main.xsl" />
	<xsl:include href="../menu.xsl" />
	
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/blogs/admin-blog-members.css" type="text/css" media="all" />
			<script type="text/javascript" src="{$baseURI}/js/blogs.js" />
			<script type="text/javascript" src="{$baseURI}/js/editBlogMembers.js" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />

			<div class="page-header">
				<xsl:call-template name="logo" />

				<xsl:call-template name="menu" />
			</div>

			<div class="page-content-wrapper">
				<div class="page-blocks">
					<xsl:call-template name="default-blocks-top" />
				</div>
	
				<div class="page-content">
					<xsl:apply-templates select="response" />
				</div>
			</div>

			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<h1>Редактирование блога</h1>
		
		<div class="tabs">
			<ul>
				<li>
					<a href="{$baseURI}/blogs/edit_blog/{@blog-id}">Информация</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
				<li class="selected">
					<a href="{$baseURI}/blogs/edit_blog_members/{@blog-id}">Участники</a>
					
					<i class="corner-mask-eee-5 tl"></i>
					<i class="corner-mask-eee-5 tr"></i>
					<i class="corner-mask-eee-5 br"></i>
					<i class="corner-mask-eee-5 bl"></i>
				</li>
			</ul>
		</div>
		
		<ul id="members_list" class="members-list">
			<xsl:apply-templates select="object[@type='blog_member']">
				<xsl:with-param name="blogId" select="@blog-id" />
			</xsl:apply-templates>
		</ul>
		
		<p>
			<img src="{$baseURI}/images/blog-members-manager-admin.png" alt="" /><xsl:text> ― назначить администратором</xsl:text><br />
			<img src="{$baseURI}/images/blog-members-manager-moderator.png" alt="" /><xsl:text> ― назначить модератором</xsl:text><br />
			<img src="{$baseURI}/images/blog-members-manager-member.png" alt="" /><xsl:text> ― снять администратора или модератора</xsl:text><br />
		</p>
	</xsl:template>
	
	<xsl:template match="object[@type='blog_member']">
		<xsl:param name="blogId" />
		<xsl:param name="userId" select="property[@name='user_id']/value" />
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		
		<li>
			<xsl:if test="@admin = '1'">
				<xsl:attribute name="class"><xsl:text>admin</xsl:text></xsl:attribute>
			</xsl:if>
			<xsl:if test="@moderator = '1'">
				<xsl:attribute name="class"><xsl:text>moderator</xsl:text></xsl:attribute>
			</xsl:if>
			
			<div class="controls" id="user_control_{$userId}">
				<button onclick="manageUser ('admin', {$userId}, {$blogId});">
					<xsl:if test="@admin = '1'">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
						<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
					</xsl:if>
					<img src="{$baseURI}/images/blog-members-manager-admin.png" alt="" />
				</button>
				<button onclick="manageUser ('moderator', {$userId}, {$blogId});">
					<xsl:if test="@moderator = '1'">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
						<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
					</xsl:if>
					<img src="{$baseURI}/images/blog-members-manager-moderator.png" alt="" />
				</button>
				<button onclick="manageUser ('member', {$userId}, {$blogId});">
					<xsl:if test="@admin = '0' and @moderator = '0'">
						<xsl:attribute name="disabled"><xsl:text>disabled</xsl:text></xsl:attribute>
						<xsl:attribute name="onclick"><xsl:text></xsl:text></xsl:attribute>
					</xsl:if>
					<img src="{$baseURI}/images/blog-members-manager-member.png" alt="" />
				</button>
			</div>
			
			<div class="name">
				<a href="{$baseURI}/user/{$userLogin}">
					<xsl:value-of select="$userLogin" />
				</a>
			</div>
		</li>
	</xsl:template>
	
</xsl:stylesheet>